<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进入房间</title>
    <style>
        .form{
            max-width: 500px;
            margin:auto;
            text-align: center;
        }
        .form .row label{
            width:20%;
            text-align: left;
        }
        
    </style>
    <script>
        function joinRoom() {
            var room_id = document.getElementById('txt_room_id').value;
            var user_id = document.getElementById('txt_user_id').value;
            var nick_name = document.getElementById('txt_nick_name').value;
            var avatar = document.getElementById('txt_avatar').value;

            location.href = buildUrl('chat.html',{room_id:room_id,user_id:user_id,nick_name:nick_name,avatar:avatar});
        }
        function buildUrl(url,param){
            if(url ==null || url == undefined)
            {
                return "";
            }

            if(url.indexOf('?')==-1){
                url+='?buildcode='+Date.now();
            }
            for(var i in param){
                url+='&'+i+'='+param[i];
            }
            return url;

        }

        //sudo ipfw add 80 allow tcp from any to any dst-port 80
    </script>
</head>
<body>
<div class="container">
    <div class="form">
        <div class="row">
            <label>房间号</label><input type="text" id="txt_room_id">
        </div>
        <div class="row"><label>用户Id</label><input type="text" id="txt_user_id"></div>
        <div class="row"><label>昵称</label><input type="text" id="txt_nick_name"></div>
        <div class="row"><label>头像</label><input type="text" id="txt_avatar"></div>
        <div class="row"><button onclick="joinRoom()">登录</button></div>
    </div>
</div>
</body>
</html>